#include "GLSceneOrthogonalMode.h"

#include "gl.h"

namespace catan
{

/*static*/ void GLSceneOrthogonalMode::begin(SDLCanvas &sdlCanvas)
{
	GLint oldMatrixMode;
	glGetIntegerv(GL_MATRIX_MODE, &oldMatrixMode);
	    glMatrixMode(GL_PROJECTION);
	    glPushMatrix();
		    glLoadIdentity();
			float halfOfHorizontalRemainder = (sdlCanvas.getWindowUnitWidth() - sdlCanvas.getClientUnitWidth())/2;
			float halfOfVerticalRemainder = (sdlCanvas.getWindowUnitHeight() - sdlCanvas.getClientUnitHeight())/2;
			glOrtho(-halfOfHorizontalRemainder, sdlCanvas.getClientUnitWidth() + halfOfHorizontalRemainder, sdlCanvas.getClientUnitHeight() + halfOfVerticalRemainder, -halfOfVerticalRemainder, -1.0f, 1.0f);
	glMatrixMode(oldMatrixMode);
}

/*static*/ void GLSceneOrthogonalMode::end()
{
	GLint oldMatrixMode;
	glGetIntegerv(GL_MATRIX_MODE, &oldMatrixMode);
	    glMatrixMode(GL_PROJECTION);
	    glPopMatrix();
	glMatrixMode(oldMatrixMode);
}

/*private*/ GLSceneOrthogonalMode::GLSceneOrthogonalMode()
{
	
}

}